cmake_minimum_required(VERSION 3.10)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

# 客户端不需rknn_api 服务端需要
if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
    set(ARCH_DIR x86)
    # 增加cpp中头文件的搜索路径
    include_directories(
        ${CMAKE_SOURCE_DIR}/sort
    )
else()
    set(ARCH_DIR arm)
    # 增加cpp中头文件的搜索路径
    include_directories(
        ${CMAKE_SOURCE_DIR}/sort
        ${CMAKE_SOURCE_DIR}/rknn_api/${ARCH_DIR}/include
    )
    # 添加动态链接库rknn
    set(rknn_libs   
        ${CMAKE_SOURCE_DIR}/rknn_api/${ARCH_DIR}/lib64/librknn_api.so
    )
endif()

# 创建一个子目录 并构建子目录
add_subdirectory(sort)

# 添加动态链接库opencv及pthread
set(opencv_libs  /usr/local/lib/libopencv_core.so
               /usr/local/lib/libopencv_highgui.so
               /usr/local/lib/libopencv_imgcodecs.so
               /usr/local/lib/libopencv_imgproc.so
               /usr/local/lib/libopencv_videoio.so
               /usr/local/lib/libopencv_video.so
               pthread
)

set(sort_libs sort)

# 开启调试选项
add_definitions("-g")

# 客户端
if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
    add_executable(rknn_client  rknn_client.cpp videoio_client.cpp 
                   detect_client.cpp track.cpp)
    target_link_libraries(rknn_client ${opencv_libs} ${sort_libs})
# 服务端
else()
    add_executable(rknn_server  rknn_server.cpp  detect_server.cpp 
                   decode.cpp   nms.cpp          videoio_server.cpp)
    target_link_libraries(rknn_server ${opencv_libs} ${rknn_libs})
endif()




